package estados;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;// slick.Input

public class juego extends BasicGameState {
	
	private Input entrada;
	private Image sprite;
	//private boolean ip;
	private float x;
	private float y;
	//private float
	private float yoyo;

	/**
	 * @byef: constructor
	 */
	
	public juego() {
		// TODO Auto-generated constructor stub
		
		/*
		 * escribimos cualquier cosa
		 * 
		 */
	}

	/**
	 * init : funcion con la que inicia el juego o este estado
	 */
	
	@Override
	public void init(GameContainer container, StateBasedGame game)
			throws SlickException {
		// TODO Auto-generated method stub

		sprite = new Image("res/pp.jpg");
		entrada = container.getInput();
		
	}
	
	/*
	 * renderiza este estado
	 * @see org.newdawn.slick.state.GameState#render(org.newdawn.slick.GameContainer, org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.Graphics)
	 */

	@Override
	public void render(GameContainer container, StateBasedGame game, Graphics g)
			throws SlickException {
		//float x,y;
		
		//g.drawRect(50, 50, 100, 100);
		//g.drawArc(300, 10, 100, 50, 150, 300);
		//g.drawString("CULO", 300, 300);
		//if(entrada.isKeyDown(Input.KEY_SPACE))
		//if(entrada.isKeyPressed(Input.KEY_SPACE))
		//	ip = true;
		//else if(!entrada.isKeyPressed(Input.KEY_SPACE))
		//	ip = false;
		
		//if(ip)
		
	//	this.setX(50);
	//	this.setY(50);
		sprite.draw(x,y, 100, 100);
		//sprite.
		

	}

	/*
	 * actualiza nuestro juego o en este caso el estado a cada paso
	 * (non-Javadoc)
	 * @see org.newdawn.slick.state.GameState#update(org.newdawn.slick.GameContainer, org.newdawn.slick.state.StateBasedGame, int)
	 */
	
	@Override
	public void update(GameContainer container, StateBasedGame game, int delta)
			throws SlickException {
		// TODO Auto-generated method stub
		
		
		if(entrada.isKeyDown(Input.KEY_W)){this.setY(y-1);}
		if(entrada.isKeyDown(Input.KEY_S)){this.setY(y+1);}
		if(entrada.isKeyDown(Input.KEY_A)){this.setY(x-1);}
		if(entrada.isKeyDown(Input.KEY_D)){this.setY(x+1);}
		if(entrada.isKeyDown(Input.KEY_UP)){this.setY(y-1);}
		if(entrada.isKeyDown(Input.KEY_DOWN)){this.setY(y+1);}
		if(entrada.isKeyDown(Input.KEY_LEFT)){this.setX(x-1);}
		if(entrada.isKeyDown(Input.KEY_RIGHT)){this.setX(x+1);}
		
		//sprite.draw(x, y, 100, 100);
	}
/*
 * getID() nos retorna la identidad del estado que deben ser valores diferentes... en este caso es 0 o la variable globalm ID
 * (non-Javadoc)
 * @see org.newdawn.slick.state.BasicGameState#getID()
 */
	@Override
	public int getID() {
		// TODO Auto-generated method stub
		return 0;
	}

	public float getX() {
		return x;
	}

	public void setX(float x) {
		this.x = x;
	}

	public float getY() {
		return y;
	}

	public void setY(float y) {
		this.y = y;
	}

}
